package com.panghu.controller;


import com.panghu.entity.ApiResult;
import com.panghu.entity.MultiQuestion;
import com.panghu.service.impl.MultiQuestionServiceImpl;
import com.panghu.utils.ApiResultHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 * 选择题题库表 前端控制器
 * </p>
 *
 * @author huahua
 * @since 2022-03-19
 */
@RestController
public class MultiQuestionController {
    @Autowired
    private MultiQuestionServiceImpl multiQuestionService;

    @GetMapping("/multiQuestionId")
    public ApiResult findOnlyQuestion() {
        List<MultiQuestion> result = multiQuestionService.list();
        return ApiResultHandler.buildApiResult(200,"查询成功",result);
    }

    @PostMapping("/MultiQuestion")
    public ApiResult add(@RequestBody MultiQuestion multiQuestion) {
        boolean res = multiQuestionService.save(multiQuestion);
        if (res) {

            return ApiResultHandler.buildApiResult(200,"添加成功",res);
        }
        return ApiResultHandler.buildApiResult(400,"添加失败",res);
    }
}

